package com.anolesoft.yr.mbus.code.mapper;

import com.anolesoft.yr.mbus.code.entity.CodeMainDO;
import com.anolesoft.yr.mbus.code.entity.CodeMaxSequenceQueryDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @author zhj
 * @date 2020/9/27 17:00
 */
@Mapper
public interface CodeMaxSequenceQueryMapper {
    @Select("<script>" +
            "select " +
            "a.objuid, " +
            "a.code_main_uid, " +
            "a.sequence_name, " +
            "a.code_item_uid, " +
            "a.property_value, " +
            "a.max_sequence, " +
            "b.code_name code_main_code_name, " +
            "b.code_desc code_main_code_desc," +
            "b.geneclass code_main_geneclass " +
            "from code_maxsequence a " +
            "right join code_main b on a.code_main_uid = b.objuid " +
            "where b.del_flag = 0 " +
            "<if test =\"o.codeMainCodeName !=null and o.codeMainCodeName != '' \">" +
            "   and b.code_name like #{o.codeMainCodeName, jdbcType=VARCHAR} " +
            "</if>" +
            "order by b.code_name" +
            "</script>")
    @Results({
            @Result(column = "objuid", property = "objuid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "code_main_uid", property = "codeMainUid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "sequence_name", property = "sequenceName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "code_item_uid", property = "codeItemUid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "property_value", property = "propertyValue", jdbcType = JdbcType.VARCHAR),
            @Result(column = "max_sequence", property = "maxSequence", jdbcType = JdbcType.BIGINT),
            @Result(column = "code_main_code_name", property = "codeMainCodeName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "code_main_code_desc", property = "codeMainCodeDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "code_main_geneclass", property = "codeMainGeneClass", jdbcType = JdbcType.VARCHAR),
    })
    List<CodeMaxSequenceQueryDO> selectPageList(@Param("o") CodeMaxSequenceQueryDO codeMaxSequenceQueryDO, Page<CodeMaxSequenceQueryDO> page);
}
